<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Create List</title>
</head>
<body>
    <input type="button" value="Cllick" id="btn">
    <div id="dv"></div>

    <script>
    document.getElementById("btn").onclick = function(){
        var names = ["郭靖", "杨过", "张无忌", "令狐冲", "韦小宝", "张三丰"];

        var str = "<ul>";
        for (var i=0; i<names.length; i++) {
            str += "<li>"+names[i]+"</li>";
        }
        str+="</ul>";
        document.getElementById("dv").innerHTML = str;

        // Add more functions to this list.
        var list = document.getElementById("dv").getElementsByTagName("li");
        for (var i=0; i<list.length; i++){
            list[i].onmouseover = function(){
                this.style.backgroundColor = "yellow";
            };
            list[i].onmouseout = function(){
                this.style.backgroundColor = "";
            };
        }
    }
    
    </script>
</body>
</html>